﻿<%@ Page Language="C#" %>
<%@ Import Namespace="System.Xml" %>

<%
    if (Request.Cookies["userID"] == null)
    {
        Response.Write("您没有登录");
        return;
    }
    else if (Request.Cookies["groupID"] == null)
    {
        Response.Write("您还没有进入到小组页面");
        return;
    }
    else
    {
        string echoString = "";
        
        //通过检查，查找xml文件并返回HTML代码
        //加载对应的xml文件
        XmlDocument xmlDocument = new XmlDocument();
        xmlDocument.Load(Server.MapPath("~/Feeds/" + Request.Cookies["groupID"].Value + "_Feeds.xml"));
        
        //选择根节点<Feeds>的所有子节点<Feed>
        XmlNodeList feeds = xmlDocument.SelectSingleNode("Feeds").ChildNodes;

        foreach (XmlElement feed in feeds)
        {
            string postDateTime = feed.GetAttribute("postDateTime");
            string userID = feed.GetAttribute("userID");
            string userName = feed.GetAttribute("userName");
            string feedID = feed.GetAttribute("ID");
            string content = feed.InnerText;

            echoString += "<div><p>" + userName + " 在 " + postDateTime + " 说：    " + (userID == Request.Cookies["userID"].Value ? "<a href=\"javascript:deletefeed(" + feedID + ");\">删除</a>" : "") + "</p><p>    " + content + "</p></div>";
        }
        
        Response.Write(echoString);
    }
%>